package com.garen.sys.dao.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import com.garen.common.BaseDaoXf;
import com.garen.orm.dao.IOrmDao;
import com.garen.sys.dao.ICommonDao;
import com.garen.utils.MapBuilder;

/*通用语句*/
@Repository
public class CommonDaoImpl extends BaseDaoXf<Map<String, Object>> implements ICommonDao {

	@Resource(name="ormmetadao")
	private IOrmDao ormdao;
	
	@PostConstruct
	private void init(){
		initOrm(Map.class);
		ormdao.setOrmdb(getOrmdb());
	}
	
	/*
	 * 查询所有表
	 * */
	public List<Map<String,Object>> allTable(){
		String sql = "select t.table_name from user_tables t ";
		Map<String,Object> paramMap = new MapBuilder()
				.build();
		return queryForList(sql, paramMap);
	}
	
	public List<Map<String,Object>> test1a(){
		String sql = "select * from firedispatch.fire_sys_org t where t.type = :type and t.pid = :pid order by t.flag asc ";
		Map<String,Object> paramMap = new MapBuilder()
				.put("type", "56650003ee6c21785c17c937")
				.put("pid", "7a7c2387d77d46b1a632bc70aabe1481")
				.build();
		return queryForList(sql, paramMap);
	}
	
	public List<Map<String,Object>> test2(String pid){
		String sql = "select * from firedispatch.fire_sys_org t where t.pid = :pid order by t.flag asc ";
		Map<String,Object> paramMap = new MapBuilder()
				.put("pid", pid)
				.build();
		return queryForList(sql, paramMap);
	}
}
